//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>
package org.jpgolay.gui.fixed;

import java.awt.Color;
import java.awt.Font;
import javax.swing.*;

public class TotalPrice extends JPanel {

    public TotalPrice() {
        totalBeforeTaxJLabel = null;
        totalBeforeTax = null;
        shippingJLabel = null;
        shipping = null;
        taxJLabel = null;
        tax = null;
        totalPaymentJLabel = null;
        totalPayment = null;
        partPaymentJLabel = null;
        partPayment = null;
        dueJLabel = null;
        due = null;
        initialize();
    }

    private void initialize() {
        setLayout(null);
        setSize(215, 104);
        setBackground(Color.white);
        setBorder(BorderFactory.createLineBorder(Color.gray, 2));
        add(getTotalBeforeTaxJLabel(), null);
        add(getTotalBeforeTax(), null);
        add(getShippingJLabel(), null);
        add(getTaxJLabel(), null);
        add(getTotalPaymentJLabel(), null);
        add(getTotalPayment(), null);
        add(getPartPaymentJLabel(), null);
        add(getDueJLabel(), null);
        add(getPartPayment(), null);
        add(getDue(), null);
        add(getShipping(), null);
        add(getTax(), null);
    }

    private JLabel getTotalBeforeTaxJLabel() {
        if (totalBeforeTaxJLabel == null) {
            totalBeforeTaxJLabel = new JLabel();
            totalBeforeTaxJLabel.setText("Total");
            totalBeforeTaxJLabel.setSize(100, 15);
            totalBeforeTaxJLabel.setLocation(5, 5);
            totalBeforeTaxJLabel.setFont(new Font("MS Sans Serif", 0, 11));
        }
        return totalBeforeTaxJLabel;
    }

    private JLabel getTotalBeforeTax() {
        if (totalBeforeTax == null) {
            totalBeforeTax = new JLabel();
            totalBeforeTax.setText("0.00");
            totalBeforeTax.setSize(100, 15);
            totalBeforeTax.setLocation(110, 5);
            totalBeforeTax.setHorizontalAlignment(4);
        }
        return totalBeforeTax;
    }

    private JLabel getShippingJLabel() {
        if (shippingJLabel == null) {
            shippingJLabel = new JLabel();
            shippingJLabel.setText("Shipping");
            shippingJLabel.setSize(100, 15);
            shippingJLabel.setLocation(5, 21);
        }
        return shippingJLabel;
    }

    private JLabel getShipping() {
        if (shipping == null) {
            shipping = new JLabel();
            shipping.setText("0.00");
            shipping.setLocation(110, 21);
            shipping.setSize(100, 15);
            shipping.setHorizontalAlignment(4);
        }
        return shipping;
    }

    private JLabel getTaxJLabel() {
        if (taxJLabel == null) {
            taxJLabel = new JLabel();
            taxJLabel.setText("Tax");
            taxJLabel.setSize(100, 15);
            taxJLabel.setLocation(5, 37);
        }
        return taxJLabel;
    }

    private JLabel getTax() {
        if (tax == null) {
            tax = new JLabel();
            tax.setText("0.00");
            tax.setLocation(110, 37);
            tax.setSize(100, 15);
            tax.setHorizontalAlignment(4);
        }
        return tax;
    }

    private JLabel getTotalPaymentJLabel() {
        if (totalPaymentJLabel == null) {
            totalPaymentJLabel = new JLabel();
            totalPaymentJLabel.setText("TOTAL");
            totalPaymentJLabel.setSize(100, 15);
            totalPaymentJLabel.setLocation(5, 53);
            totalPaymentJLabel.setFont(new Font("MS Sans Serif", 1, 12));
            totalPaymentJLabel.setBackground(new Color(255, 255, 204));
        }
        return totalPaymentJLabel;
    }

    private JLabel getTotalPayment() {
        if (totalPayment == null) {
            totalPayment = new JLabel();
            totalPayment.setText("0.00");
            totalPayment.setSize(100, 15);
            totalPayment.setLocation(110, 53);
            totalPayment.setHorizontalAlignment(4);
            totalPayment.setFont(new Font("MS Sans Serif", 1, 12));
            totalPayment.setBackground(new Color(255, 255, 204));
            totalPayment.setBorder(BorderFactory.createLineBorder(Color.blue, 1));
        }
        return totalPayment;
    }

    private JLabel getPartPaymentJLabel() {
        if (partPaymentJLabel == null) {
            partPaymentJLabel = new JLabel();
            partPaymentJLabel.setText("Part payment");
            partPaymentJLabel.setLocation(5, 69);
            partPaymentJLabel.setSize(100, 15);
        }
        return partPaymentJLabel;
    }

    private JLabel getPartPayment() {
        if (partPayment == null) {
            partPayment = new JLabel();
            partPayment.setText("0.00");
            partPayment.setSize(100, 15);
            partPayment.setLocation(110, 69);
            partPayment.setHorizontalAlignment(4);
        }
        return partPayment;
    }

    private JLabel getDueJLabel() {
        if (dueJLabel == null) {
            dueJLabel = new JLabel();
            dueJLabel.setText("Due");
            dueJLabel.setSize(100, 15);
            dueJLabel.setLocation(5, 85);
        }
        return dueJLabel;
    }

    private JLabel getDue() {
        if (due == null) {
            due = new JLabel();
            due.setText("0.00");
            due.setLocation(110, 85);
            due.setSize(100, 15);
            due.setHorizontalAlignment(4);
        }
        return due;
    }

    public void setTotalBeforeTaxLabel(String txt) {
        getTotalBeforeTaxJLabel().setText(txt);
    }

    public String getTotalBeforeTaxLabel() {
        return getTotalBeforeTaxJLabel().getText();
    }

    public void setTotalBeforeTaxValue(String txt) {
        getTotalBeforeTax().setText(txt);
    }

    public String getTotalBeforeTaxValue() {
        return getTotalBeforeTax().getText();
    }

    public void setShippingLabel(String txt) {
        getShippingJLabel().setText(txt);
    }

    public String getShippingLabel() {
        return getShippingJLabel().getText();
    }

    public void setShippingValue(String txt) {
        getShipping().setText(txt);
    }

    public String getShippingValue() {
        return getShipping().getText();
    }

    public void setTaxLabel(String txt) {
        getTaxJLabel().setText(txt);
    }

    public String getTaxLabel() {
        return getTaxJLabel().getText();
    }

    public void setTaxValue(String txt) {
        getTax().setText(txt);
    }

    public String getTaxValue() {
        return getTax().getText();
    }

    public void setTotalPaymentLabel(String txt) {
        getTotalPaymentJLabel().setText(txt);
    }

    public String getTotalPaymentLabel() {
        return getTotalPaymentJLabel().getText();
    }

    public void setTotalPaymentValue(String txt) {
        getTotalPayment().setText(txt);
    }

    public String getTotalPaymentValue() {
        return getTotalPayment().getText();
    }

    public void setPartPaymentLabel(String txt) {
        getPartPaymentJLabel().setText(txt);
    }

    public String getPartPaymentLabel() {
        return getPartPaymentJLabel().getText();
    }

    public void setPartPaymentValue(String txt) {
        getPartPayment().setText(txt);
    }

    public String getPartPaymentValue() {
        return getPartPayment().getText();
    }

    public void setDueLabel(String txt) {
        getDueJLabel().setText(txt);
    }

    public String getDueLabel() {
        return getDueJLabel().getText();
    }

    public void setDueValue(String txt) {
        getDue().setText(txt);
    }

    public String getDueValue() {
        return getDue().getText();
    }

    public void clean() {
        setTotalBeforeTaxValue("0.00");
        setShippingValue("0.00");
        setTaxValue("0.00");
        setTotalPaymentValue("0.00");
        setPartPaymentValue("0.00");
        setDueValue("0.00");
    }
    private JLabel totalBeforeTaxJLabel;
    private JLabel totalBeforeTax;
    private JLabel shippingJLabel;
    private JLabel shipping;
    private JLabel taxJLabel;
    private JLabel tax;
    private JLabel totalPaymentJLabel;
    private JLabel totalPayment;
    private JLabel partPaymentJLabel;
    private JLabel partPayment;
    private JLabel dueJLabel;
    private JLabel due;
}
